import { lazy } from 'react'
import { HomeOutlined, LineChartOutlined, FolderOpenOutlined } from '@ant-design/icons'

const Home = lazy(() => import('../pages/auth/Home'))
const Data = lazy(() => import('../pages/auth/Data'))
const Classification = lazy(() => import('../pages/auth/Classification'))

enum Permission {
  SUPER_ADMIN = '超级管理员',
  ADMIN = '管理员',
  USER = '用户'
}

const routes = [
  { path: '/home', meta: { title: '首页', Icon: HomeOutlined }, Component: Home },
  { path: '/data', meta: { title: '账单列表', Icon: LineChartOutlined }, Component: Data },
  { path: '/classification', meta: { title: '分类管理', Icon: FolderOpenOutlined, permissions: [Permission.SUPER_ADMIN] }, Component: Classification }
]

export default function getRoutes(permission?: string) {
  return !permission
    ? []
    : routes.filter(({ meta }) => {
        return !meta.permissions || meta.permissions.includes(permission! as Permission)
      })
}
